<?
/*
 * scrumbrella - Scrum board.
 *
 * Copyright (C) 2009  Gustavo N. Borgoni <gborgoni@voicemedia.com.ar>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

require_once("layout_config.php");
require_once("PHPTAL.php");

include("include/permission.php");
include("include/project.php");
include("include/html_utils.php");
include("layout_config.php");

// Check for user logged in
$user_id = permission_redirect_user("index.php");
	// Set tab selected
	$_SESSION['selected'] = 3;

	if ($_SERVER["REQUEST_METHOD"] == "POST") {
		$_SESSION['project'] = $_REQUEST['project'];
	}

	// Load the template
	$temp = new PHPTAL('templates/projectbacklog.xhtml');

	$temp->theme    = 'default';
	$temp->title    = _("Project backlog list");
	$temp->bt_new   = _("New entry");
	$temp->summary  = _("Summary");
	$temp->priority = _("Priority");
	$temp->user     = _("User");
	$temp->msg      = 0;
	$temp->id       = $_SESSION['project'];
	
	$temp->prj_title = _("Project");
	$temp->bt_select = _("Select");

	$temp->err_select = _("Please select a project");

	$projects = html_select_projectbyuser($user_id, $_SESSION['project']);
	$temp->projects = $projects;

	$pbacklog = project_backlog_list($_SESSION['project']);
	if (!$pbacklog) {
		$temp->pbacklog = 0;
		$temp->msg      = 1;
		$temp->message  = _("This project have not backlog entries");
	} else {
		$i=0;
		foreach ($pbacklog AS $backlog) {
			if ($class == 'project_item_cebra') {
				$class = 'project_item';
			} else {
				$class = 'project_item_cebra';
			}

			$prj[$i]['class']    = $class;
			$prj[$i]['summary']  = $backlog['summary'];
			$prj[$i]['priority'] = $backlog['priority'];
			$prj[$i]['user']     = $backlog['name']." ".$backlog['lastname'];
			$i++;
		}
		$temp->pbacklog = $prj;
	}

	try 
	{
		echo $temp->execute();
	}

	catch(Exception $e)
	{
		echo $e;
	}
?>
